module.exports = (opt) => {
    let replyMsg = `<xml>
    <ToUserName><![CDATA[${opt.ToUserName}]]></ToUserName> 
   <FromUserName><![CDATA[${opt.FromUserName}]]></FromUserName> 
   <CreateTime>${opt.CreateTime}</CreateTime> 
   <MsgType><![CDATA[${opt.MsgType}]]></MsgType>`;

    if (opt.MsgType === 'text') {
        replyMsg += `<Content><![CDATA[${opt.content}]]></Content>`;
    } else if (opt.MsgType === 'image') {
        replyMsg += `<Image><MediaId><![CDATA[${opt.media_id}]]></MediaId></Image>`;
    } else if (opt.MsgType === 'voice') {
        replyMsg += `<Voice><MediaId>< ![CDATA[media_id] ]></MediaId></Voice>`;
    } else if (opt.MsgType === 'video') {
        replyMsg += `<Video><MediaId><![CDATA[media_id]]></MediaId>
                <Title><![CDATA[title]]></Title>
                <Description><![CDATA[description]]></Description></Video>
                `;
    } else if (opt.MsgType === 'muisc') {
        replyMsg += ` <Music>
                    <Title><![CDATA[TITLE]]></Title>
                    <Description><![CDATA[DESCRIPTION]]></Description>
                    <MusicUrl><![CDATA[MUSIC_Url]]></MusicUrl>
                    <HQMusicUrl><![CDATA[HQ_MUSIC_Url]]></HQMusicUrl>
                    <ThumbMediaId><![CDATA[media_id]]></ThumbMediaId>
                    </Music>`;
    } else if (opt.MsgType === 'news') {
        replyMsg += `<ArticleCount>${opt.items.length}</ArticleCount>
        <Articles>`;
       opt.items.forEach(item => {
        replyMsg += `<item>
                    <Title><![CDATA[${item.title}]]></Title> 
                    <Description><![CDATA[${item.description}]]></Description>
                    <PicUrl><![CDATA[${item.picurl}]]></PicUrl>
                    <Url><![CDATA[${item.url}]]></Url>
                    </item>`;
       });
        
        replyMsg +=`</Articles>`;
    }
    replyMsg += `</xml>`;

    return replyMsg;

}